/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component,Fragment} from 'react';
import {Form, Input, Radio, Select, DatePicker, InputNumber} from 'antd';
import {connect} from 'dva';
import request from '@/utils/request';
import moment from 'moment'
const FormItem = Form.Item;
@connect(({roles}) => ({
  roles
}))
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showCustom: false
    };
  }

  componentDidMount() {
    // const that=this
    // request(`/admin/applications/${id}`, {
    //   method: 'PUT',
    //   data: {
    //   },
    // });
  }

  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 7},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };

    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form onSubmit={this.handleSubmit}>
          <FormItem label= '开始时间'
                    {...formItemLayoutWithLabel}>
            {getFieldDecorator('start_timestamp', {
              initialValue: moment(this.props.reward_commissions.start_timestamp*1000),
              rules: [{required: true}],

            })(
              <DatePicker
                style={{width:'100%'}}
                allowClear={false}
                showTime format="YYYY-MM-DD HH:mm:ss"
              />
            )}
          </FormItem>
          <FormItem label= '结束时间'
                    {...formItemLayoutWithLabel}>
            {getFieldDecorator('end_timestamp', {
              rules: [{required: true}],
              initialValue: moment(this.props.reward_commissions.end_timestamp*1000),
            })(
              <DatePicker
                style={{width:'100%'}}
                allowClear={false}
                showTime format="YYYY-MM-DD HH:mm:ss"
              />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               奖励佣金(元)
            </span>
            )}
          >
            {getFieldDecorator('reward_commission', {
              initialValue: this.props.reward_commissions ? this.props.reward_commissions.reward_commission : '',
              rules: [{required: true}],
            })(
              <InputNumber min={0} style={{width:'100%'}}/>
            )}
          </FormItem>

        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


